package org.dromara.resource.controller.api;

import org.dromara.common.core.domain.R;
import org.dromara.common.mail.utils.MailUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhou shuai
 * @date: 2024/9/26 20:31
 * @version: v1
 */
@RestController
@RequestMapping("/api/resource/mail")
public class ResourceMailApiController {

    /**
     * 发送邮件
     *
     * @param to      接收人
     * @param subject 标题
     * @param text    内容
     */
    @PostMapping("/send")
    public R<Void> sendMail(@RequestParam("to") String to, @RequestParam("subject") String subject,
                            @RequestParam("text") String text) {
        MailUtils.sendText(to, subject, text);
        return R.ok();
    }

}
